package com.example.controller.shangPinController;

import com.example.pojo.shangPinDataPojo.ResultDate;
import com.example.pojo.shangPinPojo.Journal;
import com.example.service.shangPinService.JournalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author:郭
 * @Description: TODO
 * @Date: 2022/11/23 20:26
 * @ClassName JournalController
 * 商品日志表
 */
@RequestMapping("/journal")
@Controller
public class JournalController {
    @Autowired
    private JournalService journalService;
    /**
     * @Author: 郭
     * @Date: 2022/11/23 20:28
     * @Param:
     * @Return:
     * 全查商品日志中的数据
     */
    @GetMapping("/getAll")
    @ResponseBody
    public ResultDate<Journal> getAll(){
        List<Journal> all = journalService.getAll();
        ResultDate<Journal> date = new ResultDate<>();
        date.setCount(journalService.getCount());
        date.setData(all);
        return date;
    }
    /**
     * @Author: 郭
     * @Date: 2022/12/15 18:29
     * @Param: journal
     * @Return: int
     * 添加商品的时候加一条日志进去
     */

    @GetMapping("/insertLog")
    @ResponseBody
    public int insertLog(Journal journal){
        int addLog = journalService.insertLog(journal);
        System.out.println("添加日志："+addLog);
        return addLog;
    }
    /**
     * @Author: 郭
     * @Date: 2022/12/15 18:30
     * @Param: journal
     * @Return: int
     * 修改商品信息的时候日志跟着改
     */
    @GetMapping("/updateLog")
    @ResponseBody
    public int updateLog(Journal journal){
        int update = journalService.updateLog(journal);
        System.out.println("修改日志："+update);
        return update;
    }
}
